package cn.life.business.car.service.impl;

import cn.life.business.car.dao.CarDao;
import cn.life.business.car.entity.po.Car;
import cn.life.business.car.entity.vo.CarVo;
import cn.life.business.car.service.CarService;
import cn.life.common.entity.model.CMessage;
import cn.life.common.entity.vo.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wangzhenyu
 * @Date 2018/7/6  16:53
 */
@Service
public class CarServiceImpl implements CarService{

    @Autowired private CarDao carDao;

    @Override
    public CMessage addCar(Car car) {
        return carDao.addCar(car) == 1 ? CMessage.success() : CMessage.fail("增加工厂汽车加油记录失败");
    }

    @Override
    public CMessage deleteCar(long carId) {
        return carDao.deleteCar(carId)  == 1 ? CMessage.success() : CMessage.fail("删除工厂汽车加油记录失败");
    }

    @Override
    public CMessage updateCar(Car car) {
        return carDao.update(car) == 1 ? CMessage.success() : CMessage.fail("修改工厂汽车加油记录失败");

    }

    @Override
    public CMessage getAllCarInfo(CarVo carVo) {
        Pagination<CarVo> list=carDao.getAllCarInfo(carVo);
        return CMessage.successByData(list);
    }

    @Override
    public CMessage getCar(CarVo carVo) {
        carVo=carDao.getCar(carVo);
        return CMessage.successByData(carVo);
    }


}
